package com.item 
{
	import com.data.GameData;
	import flash.display.MovieClip;
	import flash.events.Event;
	/**
	 * ...
	 * @author wen
	 */
	public class Snow extends ItemBase 
	{
		private var _startx:Number;
		
		private var _range:Number;
		private var _speed:Number;
		private var _xs:Number;
		private var _ys:Number;
		
		public function Snow(mc:MovieClip) 
		{
			super(mc);
		}
		
		override public function init():void 
		{
			_range = 5.000000E-001 + Math.random() * 5 / 10;
			_speed = 2.000000E-002 + Math.random() * 4 / 100;
			
			show();
		}
		
		/**
		 * 显示
		 */
		public function show():void
		{
			_startx = view.x;
			_xs = _range;
			
			if ((Math.random()*100) > 50)
			{
				_xs = -_xs;
			} // end if
			
			_ys = 1.500000E+000 + Math.random();
			
			//view.addEventListener(Event.ENTER_FRAME,onEnterFrameHander);
			
		}
		
		public function snowFall():void
		{
			view.x = view.x + _xs;
			if (view.x > _startx)
			{
				_xs = Math.max(_xs - _speed, -_range);
			}
			else
			{
				_xs = Math.min(_xs + _speed, _range);
			} // end else if
			
			view.y = view.y + _ys;
			
			if (Math.abs(view.y - GameData.rabbit.y) > 500)
			{
				clear();
			} // end if
		}
		
		
		override public function clear():void 
		{
			view.y = GameData.rabbit.y - Math.random() * 700;
		}
		
	}

}